	
	<div id="page-content">
			<div class="col-lg-12">
		        <div class="panel">
		            <div class="panel-heading">
		                <h3 class="panel-title">内容维护</h3>
		            </div>
		            <form id="editForm" class="panel-body form-horizontal form-padding">
		            	<input type="hidden" name="cmsContent.id" value="#(o?o.id:'')">
		            	<input type="hidden" name="cmsContent.type" value="#(type)">
		            	<input type="hidden" id="imgpath" name="cmsContent.img" value="#(o?o.img:'')">
		            	<div class="form-group">
		                    <label class="col-md-2 control-label">标题</label>
		                    <div class="col-md-9">
				                <input type="text"  name="cmsContent.title" class="form-control"  value="#(o?o.title:'')" #if(view=="detail") readonly #end />
				                <small class="help-block">请输入公告标题</small>
		                    </div>
		                </div>
		                <div class="form-group">
		                    <label class="col-md-2 control-label">起草人</label>
		                    <div class="col-md-4">
		                    	<input type="hidden" name="cmsContent.writer_id" value="#(o?o.writer_id:'')">
		                        <input type="text" name="cmsContent.writer_name" value="#(o?o.writer_name:'')" readonly class="form-control">
		                    </div>
		                    <div class="col-md-4">
		                    	<input type="hidden" name="cmsContent.writer_orgid" value="#(o?o.writer_orgid:'')">
		                        <input type="text" name="cmsContent.writer_orgname" value="#(o?o.writer_orgname:'')" readonly class="form-control">
		                    </div>
		                </div>
		                
		                <div class="form-group">
		                    <label class="col-md-2 control-label">缩略图</label>
		                    <div class="col-md-9">
		                    	<div id="uploader-demo">
							    	<!--用来存放item-->
								    <div id="filePicker">选择图片</div>
							    	<div id="fileList" class="uploader-list">
							    		#if(o.img)
							    			<img style='height: 38px;margin-left: 20px;' src='#(ctx)#(o.img)'/>
							    		#end
							    	</div>
								</div>
		                    </div>
		                </div>

		                
		                
		                <div class="form-group">
		                    <label class="col-md-2 control-label">内容</label>
		                </div>
		                <div class="form-group">
		                	<input type="hidden" name="cmsContent.content" id = "content">
		                	<input type="hidden" name="cmsContent.text_content" id = "textContent">
		                    <div id="demo-summernote">#(o?o.content:'')</div>
		                </div>
		                
			            
		                #if(view!="detail") 
			                <div class="panel-footer">
			                    <div class="row">
			                        <div class="col-sm-9 col-sm-offset-3">
			                            <button class="btn btn-warning" type="reset">重置</button>
			                            <button class="btn btn-primary" type="button" onclick="doSave()" >保存</button>
			                        </div>
			                    </div>
			                </div>
			            #end
		            </form>
		        </div>
		    </div>
	</div>
	<script>
		var type="#(type)";
		var limitReceiveCountVal={};
		if(type=="4"){//如果是帮扶认领，有限制领取数量，添加数字验证
			limitReceiveCountVal.validators = {
            	lessThan: {
					inclusive:true,
					value: 10000,
					message: '*请输入小于10000的数字'
				}
            }
		}
		function save(){
			var data = common_ajax.ajaxFunc("/admin/sys/cms/save", $('#editForm').serialize(), "json", null);
			if(data.success){
				pointLion.alertMsg("保存成功!" , "success" , "small" , function(){
					location.href = ctx+'/admin/sys/cms/getListPage?type=#(type)';//跳转到列表页
				});
			}
		}
		//表单校验
		function formValidate(){
			$('#editForm').bootstrapValidator({
	    		excluded:[":disabled"],
	            fields: {
	            	"cmsContent.title": {
	                    validators: {
	                        notEmpty: {
	                            message: '*标题不能为空'
	                        },
	                        stringLength: {
	                            max: 50,
	                            message: '*标题长度必须小于50'
	                        }
	                    }
	                },
	                "cmsContent.limit_receive_count": limitReceiveCountVal
	            }
	        }).bootstrapValidator('validate');
		}
		//进行保存
		function doSave(){
			var content = $("#demo-summernote").summernote('code');
			$("#content").val(content);
			$("#textContent").val(content.replace(/<[^>]+>/g,""));
			var validator = formValidate();//表单校验
			var va = $("#editForm").data('bootstrapValidator').isValid();
			if(va){
				save();
			}
		}
		//页面初始化
		$(document).ready(function() {
			$('#demo-summernote').summernote({
				toolbar: [    
							['style', ['style','bold', 'italic', 'underline', 'clear']],
						    ['font', ['strikethrough', 'superscript', 'subscript']],
						    ['fontname', ['fontname']],
						    ['fontsize', ['fontsize']],
						    ['color', ['color']],
						    ['para', ['ul', 'ol', 'paragraph']],
						    ['height', ['height']],
						    ['table', ['table']],
						    ['insert', ['link', 'picture', 'video']],
						    ['view', ['codeview','fullscreen']]
				      ],
				lang : 'zh-CN',
				dialogsFade : true,
				dialogsInBody : true,
				disableDragAndDrop : false,
				minHeight : '500px'
		    });
			//初始化下拉菜单
			$(".selectpicker").selectpicker({});
			//初始化上传组件
			pointLion.initUploader(null,function(data){
				$("#fileList").html("<img style='height: 38px;margin-left: 20px;' src='"+ctx+"/upload"+data.data.path+"/"+data.data.filename+"'/>");
				//添加路径
			    $("#imgpath").val("/upload"+data.data.path+"/"+data.data.filename);
			});
		});
	</script>
	<script src="#(ctx)/common/plugins/bootstrap-select/bootstrap-select.min.js"></script>